package com.jingsheng.jingshengcity.mvp.ui.activity;

import android.content.Intent;
import android.support.annotation.NonNull;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;

import com.jess.arms.base.BaseActivity;
import com.jess.arms.di.component.AppComponent;
import com.jess.arms.utils.UiUtils;
import com.jingsheng.jingshengcity.R;
import com.jingsheng.jingshengcity.di.component.DaggerLogisticsComponent;
import com.jingsheng.jingshengcity.di.module.LogisticsModule;
import com.jingsheng.jingshengcity.mvp.contract.LogisticsContract;
import com.jingsheng.jingshengcity.mvp.model.entity.TimeLineEntity;
import com.jingsheng.jingshengcity.mvp.presenter.LogisticsPresenter;
import com.jingsheng.jingshengcity.mvp.ui.adapter.LogisticsActivityAdapter;

import java.util.ArrayList;
import java.util.List;

import butterknife.BindView;

import static com.jess.arms.utils.Preconditions.checkNotNull;

/**
 * Created by Administrator on 2017/5/9.
 */

public class LogisticsActivity extends BaseActivity<LogisticsPresenter> implements LogisticsContract.View {

    @NonNull
    @BindView(R.id.rv_list)
    RecyclerView mRecyclerView;

    private List<TimeLineEntity> mList = new ArrayList<>();

    @Override
    public void setupActivityComponent(AppComponent appComponent) {
        DaggerLogisticsComponent
                .builder()
                .appComponent(appComponent)
                .logisticsModule(new LogisticsModule(this)) //请将LogisticsModule()第一个首字母改为小写
                .build()
                .inject(this);
    }

    @Override
    public int initView() {
        setTitle("查看物流");
        return R.layout.activity_logistics;
    }

    @Override
    public void initData() {

        mList.add(new TimeLineEntity("Item successfully delivered", "", 0));
        mList.add(new TimeLineEntity("Item successfully delivered", "", 1));
        mList.add(new TimeLineEntity("Item successfully delivered", "", 1));

        mRecyclerView.setLayoutManager(new LinearLayoutManager(this));
        mRecyclerView.setHasFixedSize(true);
        LogisticsActivityAdapter mLogisticsActivityAdapter = new LogisticsActivityAdapter(R.layout.adapter_logistics_item, mList);
        mLogisticsActivityAdapter.openLoadAnimation();
        mRecyclerView.setAdapter(mLogisticsActivityAdapter);
    }


    @Override
    public void showLoading() {

    }

    @Override
    public void hideLoading() {

    }

    @Override
    public void showMessage(@NonNull String message) {
        checkNotNull(message);
        UiUtils.SnackbarText(message);
    }

    @Override
    public void launchActivity(@NonNull Intent intent) {
        checkNotNull(intent);
        UiUtils.startActivity(intent);
    }

    @Override
    public void killMyself() {
        finish();
    }

    @Override
    public boolean useFragment() {
        return false;
    }

}